<template>
  <div>
    <ZgEdit
      ref="dialog"
      :view="view"
      :columns="columns"
      :formulas="formulas"
      :inputClick="inputClick"
      validUrl=""
      saveUrl=""
      @ok="$emit('ok')">
    </ZgEdit>
  </div>
</template>
<script>
export default {
  data () {
    return {
      view: { width: '60%', top: '5%', title: '新增供应链' },
      type: 'add',
      obj: null,
      columns: [
        { name: '文本', code: 'text', compType: '文本', isNeed: true, offset: 0, span: 24, defaultVal: '待配置' }
      ],
      formulas: [
        { triggerMode: '初始化时', name: '公式1', content: 'console.log("init");' },
        { triggerMode: '数据变化时', name: '公式2', content: 'console.log("update");' },
        { triggerMode: '提交时', name: '公式3', content: 'console.log("submit");' }
      ]
    }
  },
  methods: {
    open (type, json) {
      this.type = type
      let title
      if (type === 'add') {
        title = '新增供应链'
      } else if (type === 'edit') {
         title = '修改'
      } else {
         title = '详情'
      }
      this.view = { width: '60%', top: '5%', title: title }
      this.obj = Object.assign({}, this.obj, json || {})
      this.$refs.dialog.open()
    },
    inputClick (t) {
      alert(JSON.stringify(t))
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
